home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 2
/
Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso
/
Aminet
/
comm
/
term
/
term34Source.lha
/
EmulationPanel.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-16
|
11KB
|
389 lines
/*
** EmulationPanel.c
**
** Editing panel for emulation configuration
**
** Copyright © 1990-1993 by Olaf `Olsen' Barthel & MXM
** All Rights Reserved
*/
#include "termGlobal.h"
enum { GAD_CURSORKEYS, GAD_NUMKEYPAD, GAD_WRAPCURSOR, GAD_WRAPCHARACTERS,
GAD_CLS_RESETS_CURSOR,GAD_INSERTMODE, GAD_NEWLINE, GAD_FONTSCALE, GAD_SCROLLING,
GAD_DESTRUCTIVE_BACKSPACE, GAD_SWAP_BS_DEL, GAD_PRINTER_CONTROL,
GAD_ANSWERBACK, GAD_USE, GAD_CANCEL, GAD_DEFAULT };
STATIC STRPTR ControlMode[3],
ScrollMode[3],
ScaleFontText[3];
STATIC struct Gadget *
CreateAllGadgets(struct Configuration *Config,struct Gadget *GadgetArray[],struct Gadget **GadgetList,BYTE *Default)
{
struct Gadget *Gadget;
struct NewGadget NewGadget;
UWORD Counter = 0;
SZ_SizeSetup(Window -> WScreen,&UserFont,TRUE);
LocalizeString(ControlMode,MSG_EMULATIONPANEL_STANDARD_MODE_TXT,MSG_EMULATIONPANEL_APPLICATION_MODE_TXT);
LocalizeString(ScaleFontText,MSG_EMULATIONPANEL_NORMAL_SCALE_TXT,MSG_EMULATIONPANEL_HALF_WIDTH_TXT);
LocalizeString(ScrollMode,MSG_EMULATIONPANEL_JUMP_TXT,MSG_EMULATIONPANEL_SMOOTH_TXT);
memset(&NewGadget,0,sizeof(struct NewGadget));
if(Gadget = CreateContext(GadgetList))
{
SZ_AddLeftOffset(SZ_LeftOffsetDelta(MSG_EMULATIONPANEL_CURSOR_KEYS_GAD,MSG_EMULATIONPANEL_ANSWERBACK_MESSAGE_GAD));
SZ_ResetMaxWidth();
SZ_UpdateMaxWidth(CYCLE_KIND,NULL,0,ControlMode);
SZ_UpdateMaxWidth(CYCLE_KIND,NULL,0,ScrollMode);
SZ_UpdateMaxWidth(CYCLE_KIND,NULL,0,ScaleFontText);
SZ_UpdateMaxWidth(STRING_KIND,NULL,20,NULL);
SZ_SetWidth(SZ_ResetMaxWidth());
NewGadget . ng_GadgetText = LocaleString(MSG_EMULATIONPANEL_CURSOR_KEYS_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CYCLE_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
GTCY_Labels, ControlMode,
GTCY_Active, Config -> EmulationConfig -> CursorMode,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_EMULATIONPANEL_NUMERIC_KEYPAD_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CYCLE_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
GTCY_Labels, ControlMode,
GTCY_Active, Config -> EmulationConfig -> NumericMode,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_EMULATIONPANEL_WRAP_CURSOR_MOVES_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
GTCB_Checked, Config -> EmulationConfig -> CursorWrap,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_EMULATIONPANEL_WRAP_CHARACTERS_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
GTCB_Checked, Config -> EmulationConfig -> LineWrap,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_EMULATIONPANEL_CLS_RESETS_CURSOR_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
GTCB_Checked, Config -> EmulationConfig -> CLSResetsCursor,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_EMULATIONPANEL_INSERT_MODE_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
GTCB_Checked, Config -> EmulationConfig -> InsertMode,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_EMULATIONPANEL_NEW_LINE_MODE_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
GTCB_Checked, Config -> EmulationConfig -> NewLineMode,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_EMULATIONPANEL_FONT_SCALE_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CYCLE_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
GTCY_Labels, ScaleFontText,
GTCY_Active, Config -> EmulationConfig -> FontScale,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_EMULATIONPANEL_SMOOTH_SCROLLING_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CYCLE_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
GTCY_Labels, ScrollMode,
GTCY_Active, Config -> EmulationConfig -> ScrollMode,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_EMULATIONPANEL_DESTRUCTIVE_BACKSPACE_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
GTCB_Checked, Config -> EmulationConfig -> DestructiveBackspace,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_EMULATIONPANEL_SWAP_BS_AND_DEL_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
GTCB_Checked, Config -> EmulationConfig -> SwapBSDelete,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_EMULATIONPANEL_PRINTER_CONTROL_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
GTCB_Checked, Config -> EmulationConfig -> PrinterEnabled,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_EMULATIONPANEL_ANSWERBACK_MESSAGE_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(STRING_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
GTST_MaxChars, 79,
GTST_String, Config -> EmulationConfig -> AnswerBack,
TAG_DONE);
SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_GLOBAL_USE_GAD),0,NULL);
SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_GLOBAL_CANCEL_GAD),0,NULL);
SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_GLOBAL_DEFAULT_GAD),0,NULL);
SZ_SetWidth(SZ_ResetMaxWidth());
NewGadget . ng_GadgetText = LocaleString(MSG_GLOBAL_USE_GAD);
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_Flags = 0;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
SZ_AlignExtra, TRUE,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
SZ_AlignLeft, TRUE,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_GLOBAL_CANCEL_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
SZ_AlignRight, TRUE,
TAG_DONE);
if(Default)
{
NewGadget . ng_GadgetText = LocaleString(MSG_GLOBAL_DEFAULT_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
SZ_Adjust, TRUE,
SZ_AutoWidth, TRUE,
SZ_AlignCentre, TRUE,
TAG_DONE);
}
}
return(Gadget);
}
BYTE
EmulationPanel(struct Configuration *Config,BYTE *Default)
{
struct Window *PanelWindow;
struct Gadget *GadgetList;
struct Gadget *GadgetArray[GAD_DEFAULT + 1];
BYTE Changed = FALSE;
SaveConfig(Config,PrivateConfig);
if(CreateAllGadgets(Config,GadgetArray,&GadgetList,Default))
{
if(PanelWindow = OpenWindowTags(NULL,
WA_Left, GetScreenLeft(Window) + (GetScreenWidth(Window) - SZ_GetWindowWidth()) / 2,
WA_Top, GetScreenTop(Window) + (GetScreenHeight(Window) - SZ_GetWindowHeight()) / 2,
WA_Width, SZ_GetWindowWidth(),
WA_Height, SZ_GetWindowHeight(),
WA_Activate, TRUE,
WA_DragBar, TRUE,
WA_DepthGadget, TRUE,
WA_RMBTrap, TRUE,
WA_DepthGadget, TRUE,
WA_CloseGadget, TRUE,
WA_CustomScreen,Window -> WScreen,
WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_GADGETDOWN | IDCMP_ACTIVEWINDOW | IDCMP_VANILLAKEY | IDCMP_RAWKEY | STRINGIDCMP | BUTTONIDCMP | CHECKBOXIDCMP | CYCLEIDCMP,
WA_Title, LocaleString(MSG_EMULATIONPANEL_EMULATION_PREFERENCES_TXT),
TAG_DONE))
{
struct IntuiMessage *Massage;
ULONG IClass,Code;
struct Gadget *Gadget;
BYTE Terminated = FALSE;
GuideContext(CONTEXT_EMULATION);
PushWindow(PanelWindow);
AddGList(PanelWindow,GadgetList,(UWORD)-1,(UWORD)-1,NULL);
RefreshGList(GadgetList,PanelWindow,NULL,(UWORD)-1);
GT_RefreshWindow(PanelWindow,NULL);
ActiveGadget = NULL;
ClrSignal(SIG_BREAK);
while(!Terminated)
{
if(Wait(PORTMASK(PanelWindow -> UserPort) | SIG_BREAK) & SIG_BREAK)
{
SaveConfig(PrivateConfig,Config);
break;
}
while(!Terminated && (Massage = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort)))
{
IClass = Massage -> Class;
Code = Massage -> Code;
Gadget = (struct Gadget *)Massage -> IAddress;
GT_ReplyIMsg(Massage);
KeySelect(GadgetArray,GAD_CANCEL,Code,PanelWindow,&Gadget,&IClass,&Code);
if(IClass == IDCMP_GADGETDOWN)
{
if((Gadget -> GadgetType & GTYP_GTYPEMASK) == GTYP_STRGADGET)
ActiveGadget = Gadget;
}
if(IClass == IDCMP_ACTIVEWINDOW && ActiveGadget)
ActivateGadget(ActiveGadget,PanelWindow,NULL);
if(IClass == IDCMP_CLOSEWINDOW)
{
SaveConfig(PrivateConfig,Config);
Terminated = TRUE;
}
if(IClass == IDCMP_GADGETUP)
{
switch(Gadget -> GadgetID)
{
case GAD_USE:
Terminated = TRUE;
Config -> EmulationConfig -> CursorWrap = SZ_GetChecked(GadgetArray[GAD_WRAPCURSOR]);
Config -> EmulationConfig -> LineWrap = SZ_GetChecked(GadgetArray[GAD_WRAPCHARACTERS]);
Config -> EmulationConfig -> InsertMode = SZ_GetChecked(GadgetArray[GAD_INSERTMODE]);
Config -> EmulationConfig -> NewLineMode = SZ_GetChecked(GadgetArray[GAD_NEWLINE]);
Config -> EmulationConfig -> DestructiveBackspace = SZ_GetChecked(GadgetArray[GAD_DESTRUCTIVE_BACKSPACE]);
Config -> EmulationConfig -> SwapBSDelete = SZ_GetChecked(GadgetArray[GAD_SWAP_BS_DEL]);
Config -> EmulationConfig -> PrinterEnabled = SZ_GetChecked(GadgetArray[GAD_PRINTER_CONTROL]);
Config -> EmulationConfig -> CLSResetsCursor = SZ_GetChecked(GadgetArray[GAD_CLS_RESETS_CURSOR]);
strcpy(Config -> EmulationConfig -> AnswerBack,SZ_GetString(GadgetArray[GAD_ANSWERBACK]));
Changed = TRUE;
break;
case GAD_CANCEL:
Terminated = TRUE;
SaveConfig(PrivateConfig,Config);
break;
case GAD_DEFAULT:
*Default = TRUE;
Terminated = TRUE;
break;
case GAD_CURSORKEYS:
Config -> EmulationConfig -> CursorMode = Code;
break;
case GAD_NUMKEYPAD:
Config -> EmulationConfig -> NumericMode = Code;
break;
case GAD_FONTSCALE:
Config -> EmulationConfig -> FontScale = Code;
break;
case GAD_SCROLLING:
Config -> EmulationConfig -> ScrollMode = Code;
break;
}
}
}
}
RemoveGList(PanelWindow,GadgetList,(UWORD)-1);
PopWindow();
CloseWindow(PanelWindow);
}
FreeGadgets(GadgetList);
}
/* Set up the window size. */
ScreenSizeStuff();
return(Changed);
}